<extend name='layout:index'/>
<block name='content'>
	<body style="overflow-x:hidden">
<form action="__MODULE__/switch/cashTrans" method="post"  onSubmit="return checkCashFrom(this)">
	
		<div class="table-responsive" style="margin-left:10px">
		
		<table class="table table-bordered">
			<tbody><tr>

			</tr>
			<tr>
				<td>用户名：<?php echo $_SESSION['users']['user_name']?>
				</td><td>会员ID：<?php echo $_SESSION['users']['user_id']?>
				</td><td>账户剩余现金积分：$<span id='cash_money'>{$user.user_money1}</span>
			</td></tr>
		</tbody></table>
		
		</div>
		
		
		
	<div style="padding-left:30px;">
		<div class="form-group" style="margin-top:40px">
		<div class="form-inline">
    		<label>转出现金积分数量：</label>
   			<input id="cash_num" name="cash_num" class="form-control"  onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" type="text"　>
   		</div>
  		</div>
		<div class="form-group" style="margin-top:40px">
		<div class="form-inline">
    		<label>安全密码：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
   			<input id="repassword" name="repassword" class="form-control" type="password">
   		</div>
   		</div>
   		<div class="form-group" style="margin-top:40px;padding-left:15%">
		<div class="form-inline">
   		   <input type="submit" class="btn btn-default" style="background: #0073b7;color:#ffffff;"  >
		</div>
   		</div>

</div>
</form>
	
<script language="javascript">

		function checkCashFrom(){
			$('.btn').attr('disabled',true);
			var cash_money = $('#cash_money').text();
			var money = cash_money - $('#cash_num').val();
			if($('#cash_num').val() == ''){
						var txt=  "现 金 积 分 未 填 ";
	                        window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.error);
	                    return false;
			}
			
			if(money<0){
						var txt=  "现 金 积 分 不 足 ";
	                        window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.error);
	                    return false;
			}
			var k = false;
			var repassword = $('#repassword').val();
			$.ajax({
				type: 'POST' ,
				url: '/home/switch/cashAjax',
				data:{repassword:repassword},
				dataType : 'html',
	            async : false,
	            success : function(str){
	            	 if(str==2){
	                     var txt=  "安 全 密 码 错 误";
	                        window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.error);
	                    return false;
	                }
	                if(str==1){
	                	k = true;
	                }
	            }
			})
			return k;
		}

		

</script>
</body>
</block>